"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useRefAndForward = useRefAndForward;

var _react = require("react");

function useRefAndForward(initialValue, forwardedRef) {
  var ref = (0, _react.useRef)(initialValue);

  var forward = function forward(instance) {
    ref.current = instance;

    if (typeof forwardedRef === 'function') {
      forwardedRef(instance);
    } else if (forwardedRef) {
      forwardedRef.current = instance; // eslint-disable-line no-param-reassign
    }
  };

  return [ref, forward];
}